package com.xuxk.project.oauth.service.impl;

import com.github.pagehelper.Page;
import com.xuxk.project.oauth.bean.XuxkUser;
import com.xuxk.project.oauth.dao.XuxkUserDao;
import com.xuxk.project.oauth.dto.XuxkUserDto;
import com.xuxk.project.oauth.service.XuxkUserService;
import com.xuxk.project.oauth.vo.XuxkUserVo;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Manager implementation for XuxkUser, responsible for business processing, and communicate between web and persistence layer.
 * @author 橙云科技有限公司
 */
@Service
public class XuxkUserServiceImpl implements XuxkUserService {

	@Resource
	private XuxkUserDao xuxkUserDao;
    @Override
	public Page<XuxkUserVo>  listXuxkUsers(Map<String, Object> map, RowBounds rowBounds){


        Page<XuxkUserVo> xuxkUserPage =  xuxkUserDao.listXuxkUsers(map,rowBounds);
		return xuxkUserPage;
	}
    @Override
	public List<XuxkUser> listXuxkUserByDto(XuxkUserDto dto){
        /**
         * 使用例子：
		 *
         * OaEmployeeDto dto1 = new OaEmployeeDto();
         * 		dto1.createCriteria()
         * 			.andIdEqualTo(1L)
         * 			.andFnumberEqualTo("NLW17004");
         * 	xuxkUserDao.listByDto(dto1);
         */

		return xuxkUserDao.listByDto(dto);
	}

    @Override
	public void deleteXuxkUser(Integer id )  {
	    Map<String,Object> map = new HashMap<>();
        map.put("id",id);

		xuxkUserDao.deleteByPrimaryKey(map);
	}

    /**
    * 全量更新
    * @return
    */
    @Override
    public Integer updateXuxkUser(XuxkUser xuxkUser)  {



        return xuxkUserDao.updateXuxkUser(xuxkUser);
    }

    /**
    * 部分更新
	* @return
	*/
    @Override
    public Integer patchUpdateXuxkUser(XuxkUser xuxkUser)  {


        return xuxkUserDao.patchUpdateXuxkUser(xuxkUser);

    }

    /**
    * 新增
	* @return
	*/
    @Override
    public Integer insertXuxkUser(XuxkUser xuxkUser)  {


		xuxkUserDao.insertSelective(xuxkUser);

        return xuxkUser.getId();

    }
    @Override
    public XuxkUser getXuxkUser(Integer id ){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);

        return xuxkUserDao.getXuxkUser(map);
    }

}